package com.java.jvm.demo.chapter02;

/**
 * 早期绑定和晚期绑定，也叫静态链接和动态链接
 * @author wangning
 * @create 2021-10-20 21:31
 */
class Animal {
	public void eat() {
		System.out.println("动物进食");
	}
}
//Huntable 捕猎
interface Huntable {
	void hunt();
}

class Cat extends Animal implements Huntable {

	public Cat(){
		super();//早期绑定
	}

	public Cat(String name) {
		this();//早期绑定
	}
	@Override
	public void eat() {
		System.out.println("猫吃鱼");
	}

	@Override
	public void hunt() {


	}
}

class Dog extends Animal implements Huntable {

	@Override
	public void eat() {
		System.out.println("吃骨头");
	}

	@Override
	public void hunt() {
		System.out.println("捕食耗子，天经地义");
	}

}


public class AnimalTest {
	public void showAnimal(Animal animal) {
		animal.eat();//表现为晚期绑定
	}

	public void showHuntable(Huntable huntable) {
		huntable.hunt();//表现为晚期绑定

	}

}
